package com.mobilekites.util;

import android.content.Context;

import com.android.volley.AuthFailureError;
import com.android.volley.NetworkError;
import com.android.volley.ServerError;
import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;
import com.mobilekites.R;
import com.mobilekites.api.ReceiveServerError;

public class ErrorStrings {
	public static String get(Context context, VolleyError volleyerror) {
		String s = context.getString(R.string.kites_error_unknown);
		if (volleyerror instanceof AuthFailureError) {
			s = context.getString(R.string.kites_error_authenticate);
		} else if (volleyerror instanceof ServerError) {
			s = context.getString(R.string.kites_error_server);
		} else if (volleyerror instanceof TimeoutError) {
			s = context.getString(R.string.kites_error_timeout);
		} else if (volleyerror instanceof NetworkError) {
			s = context.getString(R.string.kites_error_no_connection);
		} else if (volleyerror instanceof ReceiveServerError) {
			s = ((ReceiveServerError) volleyerror).getMessage();
		}
		return s;
	}
}
